﻿using System;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using Besture.Bll;
using Besture.Common;

namespace Besture.UI.ClassHelper
{
    public class ClientPage : BaseClientPage
    {
        #region 登录过期
        /// <summary>
        /// 构造函数.
        /// </summary>
        public ClientPage()
        {
            this.Load += new EventHandler(ClientPage_Load);
        }

        /// <summary>
        /// 页面加载事件.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
        void ClientPage_Load(object sender, EventArgs e)
        {
            //判断是否登录
            if (LoginUserInfo == null)
            {
                HttpContext.Current.Response.Redirect("/User/Login.aspx");
            }
        }

        #endregion



        protected override void OnLoad(EventArgs e)
        {
            //SEO
            string currentPageName = Page.Request.Url.Segments[Page.Request.Url.Segments.Length - 1];
            string pageKey = currentPageName.Substring(0, currentPageName.LastIndexOf("."));

            DataTable dt = new SeoDac().GetDataBySeoKey(pageKey);
            if (dt.Rows.Count > 0)
            {
                Page.Title = dt.Rows[0]["SeoTitle"].ToString();
                HtmlMeta keywordsMeta = new HtmlMeta();
                keywordsMeta.Name = "keywords";
                keywordsMeta.Content = dt.Rows[0]["SeoKeyword"].ToString();
                Page.Header.Controls.Add(keywordsMeta);

                HtmlMeta discriptionMeta = new HtmlMeta();
                discriptionMeta.Name = "description";
                discriptionMeta.Content = dt.Rows[0]["SeoDescription"].ToString();
                Page.Header.Controls.Add(discriptionMeta);
            }
            base.OnLoad(e);

        }
    }
}